<include file="public@header" />
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('grade/index')}">所有成绩</a></li>
        <li><a href="{:url('grade/add')}">添加成绩</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="get" action="{:url('grade/index')}">
        成绩名称:
        <input type="text" class="form-control" name="name" style="width: 140px;" value="{$Request.param.name}" placeholder="请输入成绩名称">
        <input type="submit" class="btn btn-primary" value="搜索" />
        <a class="btn btn-danger" href="{:url('grade/index')}">清空</a>
    </form>
    <div style="margin-bottom: 15px">
        <a class="btn btn-primary" href="{:url('grade/exportExcel')}">导出Excel</a>
        <a class="btn btn-danger " id="import">从Excel导入</a>
        <a class="btn btn-primary" href="{:url('grade/download')}">下载导入模板</a>
    </div>
    <table class="table table-hover table-bordered">
        <thead>
        <tr>
            <th width="16"><label><input type="checkbox" class="js-check-all" data-direction="x"
                                         data-checklist="js-check-x"></label></th>
            <th width="40">ID</th>
            <th>学生名称</th>
            <th>科目名称</th>
            <th>成绩名称</th>
            <th width="160">{:lang('ACTIONS')}</th>
        </tr>
        </thead>
        <tbody>
        <foreach name="grade" item="vo">
            <tr>
                <td><input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                           value="{$vo.id}"></td>
                <td>{$vo.id}</td>
                <td>{$vo.student_name}</td>
                <td>{$vo.course_name}</td>
                <td>{$vo.name}</td>
                <td>
                    <a class="btn btn-xs btn-primary" href='{:url("grade/edit",array("id"=>$vo["id"]))}'>{:lang('EDIT')}</a>
                    <a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('grade/delete',array('id'=>$vo['id']))}">{:lang('DELETE')}</a>
                </td>
            </tr>
        </foreach>
        </tbody>
    </table>
    <div class="pagination">{$page}</div>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script src="__STATIC__/layui/layui.all.js"></script>
<script>
    //使用ajax将所选的文件异步发送给php导入方法
    layui.use('upload',function () {
        var upload = layui.upload;
        var uploadInst = upload .render({
            elem:"#import",
            url:"{:url('grade/importExcel')}",
            accept:'file',
            done:function (res) {
                //展示导入结果
                layer.msg('成功导入'+res.success+'条数据');
                //延迟两秒刷新页面
                setTimeout(function () {
                    location.reload();
                },2000)
            }
        });
    })
</script>

</body>
</html>